package com.swinw.asumall.cart.vo;

import java.math.BigDecimal;
import java.util.List;

/**
 * 购物车
 */
public class Cart {

    private List<CartItem> itmes;
    private Integer countNum;//商品总数
    private Integer countType;//类型总数
    private BigDecimal totalAmount;//总价
    private BigDecimal reduce = new BigDecimal("0.00");//减免的价格

    public List<CartItem> getItmes() {
        return itmes;
    }

    public void setItmes(List<CartItem> itmes) {
        this.itmes = itmes;
    }

    public Integer getCountNum() {
        int count;
        if(itmes != null && itmes.size()>0){
            count = itmes.stream().mapToInt(CartItem::getCount).sum();
        }
        return countNum;
    }

    public void setCountNum(Integer countNum) {
        this.countNum = countNum;
    }

    public Integer getCountType() {
        int count = 0;
        if (itmes != null && itmes.size() > 0) {
            for (CartItem item :
                    itmes) {
                count += 1;
            }
        }
        return count;
    }

    public void setCountType(Integer countType) {
        this.countType = countType;
    }

    public BigDecimal getTotalAmount() {

        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public BigDecimal getReduce() {
        return reduce;
    }

    public void setReduce(BigDecimal reduce) {
        this.reduce = reduce;
    }
}
